#pragma once
#include "TimeTable.h"
#include "CurrentTimes.h"

class User
{
public:
    User(const TCHAR* user, const TCHAR* subKey);
    ~User(void);
protected:
    BOOL m_isCurrent;
    TCHAR m_User[100];
    TCHAR m_KeyStr[512];
    TCHAR m_Path[MAX_PATH];
    TCHAR m_Profile[MAX_PATH];
    BOOL m_controlled;
    TimeTable m_timeTable;
    CurrentTimes m_currentTimes;
public:
    const TCHAR* Name(void) { return m_User; }
    const TCHAR* KeyString(void) { return m_KeyStr; }
    const TCHAR* PathString(void) { return m_Path; }
    const TCHAR* ProfilePath(void) { return m_Profile; }

    BOOL IsCurrent(void) { return m_isCurrent; }
    BOOL IsControlled(void) { return m_controlled; }
    void Control(BOOL controlled) { m_controlled = controlled; }

    UINT DayTime(int day) { return m_timeTable.Table(day)->Time(); }
    void DayTime(int day, UINT time) { m_timeTable.Table(day)->Time(time); }

    UINT CurrentDayTime(int day) { return m_currentTimes.CurrentDayTime(day); }

    UINT WeekTime() { return m_timeTable.Week(); }
    void WeekTime(UINT time) { m_timeTable.Week(time); }

    UINT CurrentWeekTime() { return m_currentTimes.CurrentWeekTime(); }

    BOOL IsAllowed(int day, int idx) { return m_timeTable.Table(day)->Allowed(idx); }
    void Allow(int day, int idx, BOOL b) { m_timeTable.Table(day)->Allow(idx, b); }

    int ReadConfig(const BYTE* config);
    int SaveConfig(BYTE* config);

    int ReadCurrent(const BYTE* current) { return m_currentTimes.ReadCurrent(current); }
    int SaveCurrent(BYTE* current) { return m_currentTimes.SaveCurrent(current); }

    void UpdateTimes(SYSTEMTIME& st, int interval) { m_currentTimes.UpdateTimes(st, interval); }
    UserStatus HasToStop(SYSTEMTIME& st);
    void InitDate(SYSTEMTIME& st) { m_currentTimes.InitDate(st); }
    int TimeRemainsSchedule(SYSTEMTIME& st) { return m_timeTable.TimeRemainsSchedule(st); }
};

